package com.hafiery.sdk.bluetooth.transport.constant;

public enum ErrorCode {
    ERRCODE_ERROR_UNKNOWN(0xee,"未知错误码"),
    ERRCODE_SUCCESS(0x00,"请求正常"),
    ERRCODE_DEVICE_BUSY(0x11,"设备忙"),
    ERRCODE_INVALID_CMD(0x12,"无效的命令"),
    ERRCODE_LOW_POWER(0x13,"设备电量低"),
    ERRCODE_NOT_SUPPORT_CMD(0x14,"设备不支持该命令"),
    ERRCODE_UNKNOWN_CMD(0x15,"未知命令"),
    ERRCODE_SAVE_FAILED(0x16,"存储失败"),
    ERRCODE_NO_SPACE(0x17,"设备空间不足"),
    ERRCODE_DEVICE_IS_RECORDING(0x18,"设备正在录音"),
    ERRCODE_FORMAT_ROM_FAILED(0x19,"设备格式化失败"),
    ERRCODE_SEND_FILE_FAILED(0x20,"文件发送失败"),
    ERRCODE_DEVICE_ALREADY_BIND(0x1A,"设备已被绑定"),
    ERRCODE_BIND_ID_INVALID(0x1B,"待绑定的用户ID不合法"),
    ERRCODE_WIFI_SSID_INVALID(0x1C,"Wifi连接失败:SSID无效"),
    ERRCODE_RECORD_NOT_START(0x1E,"设备未录音");



    private int code;
    private String message;
    ErrorCode(int code, String message){
        this.code=code;
        this.message=message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static ErrorCode of(int code){
        for (ErrorCode errorCode:ErrorCode.values()){
            if(errorCode.code == code)
                return errorCode;
        }
        return ERRCODE_ERROR_UNKNOWN;
    }

}
